Word OLE - Header editing

I have to export a module to Word. There i have a template and i want to change the header text in this template.

What i wanted to do is looping through the Story Ranges until the Primary Header is found. Here is my script:

OleAutoObj objStoryRanges
oleGet(objDoc,"StoryRanges",objStoryRanges)
OleAutoObj objStoryRange
clear objArgBlock
put(objArgBlock, 1)
oleMethod(objStoryRanges, cMethodItem, objArgBlock, objStoryRange)

int temp = 0
oleGet(objStoryRange, "StoryType", temp)

while ((temp != wdPrimaryHeaderStory)){
OleAutoObj objStoryRangeNext
oleGet(objStoryRanges,"NextStoryRange",objStoryRangeNext)
objStoryRange = objStoryRangeNext
oleGet(objStoryRange, "StoryType", temp)
}

But i'm not able to step to the next story range with "NextStoryRange".

Any idea would be helpful as i am trying to do this for hours now.
SystemAdmin - Mon Feb 14 15:12:22 EST 2011